/* **********************************************************************************
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* This source code is subject to terms and conditions of the Shared Source License
* for DSL Editor PowerToy. A copy of the license can be found in the License.htm file
* at the root of this distribution. If you can not locate the Shared Source License
* for DSL Editor PowerToy, please obtain a copy from: http://www.codeplex.com/dsltreegrideditor/Project/License.aspx.
* By using this source code in any fashion, you are agreeing to be bound by
* the terms of the Shared Source License for DSL Editor PowerToy.
*
* You must not remove this notice, or any other, from this software.
*
* **********************************************************************************/
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace DslEditorPowerToy.Controls.VirtualTreeGrid
{
    internal static class NativeMethods
    {
        internal const int LB_GETITEMRECT = 0x0198;

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, out Rectangle rect);
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
        [DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
        public static extern bool RedrawWindow(IntPtr hwnd, [In] ref Rectangle rcUpdate, IntPtr hrgnUpdate, RedrawWindowFlags flags);

        [StructLayout(LayoutKind.Sequential)]
        internal struct Rectangle
        {
            internal int Left;
            internal int Top;
            internal int Right;
            internal int Bottom;

            public Rectangle(int left, int top, int right, int bottom)
            {
                this.Left = left;
                this.Top = top;
                this.Right = right;
                this.Bottom = bottom;
            }
            public Rectangle(System.Drawing.Rectangle rect)
            {
                this.Left = rect.Left;
                this.Top = rect.Top;
                this.Right = rect.Right;
                this.Bottom = rect.Bottom;
            }
        }

        [Flags]
        internal enum RedrawWindowFlags : int
        {
            Invalidate = 0x0001,
            InternalPaint = 0x0002,
            Erase = 0x0004,
            Validate = 0x0008,
            NoInternalPaint = 0x0010,
            NoErase = 0x0020,
            NoChildren = 0x0040,
            AllChildren = 0x0080,
            UpdateNow = 0x0100,
            EraseNow = 0x0200,
            Frame = 0x0400,
            NoFrame = 0x0800,
        }
    }
}
